package com.weixing.mall.provider.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.weixing.mall.provider.mapper.GoodsIntroMapper;
import com.weixing.mall.provider.model.domain.GoodsIntro;
import com.weixing.mall.provider.model.dto.GoodsIntroDto;
import com.weixing.mall.provider.service.IGoodsIntroService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author wx
 * @Date 2019/8/12 15:53
 * @Version 1.0
 */
/**
 * <p>
 * 商品模块-商品描述表 服务实现类
 * </p>
 *
 * @author Small
 * @since 2019-11-20
 */
@Service
public class GoodsIntroServiceImpl extends ServiceImpl<GoodsIntroMapper, GoodsIntro> implements IGoodsIntroService {
    @Autowired
    private GoodsIntroMapper goodsIntroMapper;

    @Override
    public void save(GoodsIntroDto goodsIntroDto) {
        GoodsIntro goodsIntro = new GoodsIntro();
        BeanUtils.copyProperties(goodsIntroDto,goodsIntro);
        //商品详情，先删除，再新增
        if(goodsIntroDto!=null){
            goodsIntroMapper.deleByGoodsId(goodsIntroDto.getGoodsId());
        }
        goodsIntroMapper.insert(goodsIntro);

    }
    @Override
    public GoodsIntro selectByGoodsId(Long goodsId) {
        return goodsIntroMapper.selectByGoodsId(goodsId);
    }
}
